package com.mpp.admin.shiro;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author mapp
 * @des
 * @date 2019/2/20
 */
public class RedisCacheManager<T> implements CacheManager {

    private RedisTemplate<String, T> redisTemplate;

    @Override
    public <K, V> Cache<K, V> getCache(String s) throws CacheException {
        return (Cache<K, V>) new RedisCache<>(redisTemplate);
    }

    public RedisCacheManager(RedisTemplate<String, T> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
}
